Audit

Set Audit Fields on Update

Description
This customization shows how to implement an audit trail by creating and modifying audit fields in a database record.
Variables
Table Name
Select the name of the database table
Audit Field
Select an audit field in the table
Applies to
RecordClass class
Code
 
/// 
/// This custom method is an event handler for the update event in the Data Access layer.
/// 
private void Audit_Update(object sender, System.ComponentModel.CancelEventArgs e)
{
	/// You can modify the following sample code to fit specific need
    
    // string s;
    // s = (this.${Audit Field} + "Inserted by: " + BaseClasses.Utils.SecurityControls.GetCurrentUserName() + " on " + DateTime.Now.ToString() + ".").Trim();	    

    // this.${Audit Field} = s;
    
    // Update other fields
    // this.user= "loggedInUser";   
}
     
Applies to
CSharpRecordClassConstructor class
Code
 
    // The following line will be inserted inside the
    // constructor for table record class.
    this.UpdatingRecord += 
        new BaseClasses.IRecordWithTriggerEvents.UpdatingRecordEventHandler(this.Audit_Update);
     

Terms of Service Privacy Statement